﻿using FinancePortal.Domain.Model;
using System.ComponentModel.DataAnnotations;

namespace FinancePortal.Web.Models
{
    public class AreaViewModel
    {
        public int Id { get; set; }

        [Required]
        [StringLength(50)]
        public string Name { get; set; }

        public int? ParentAreaId { get; set; }

        public bool AreaClient { get; set; }

        public static Area ToModel(AreaViewModel view)
        {
            return new Area 
            {
                Id = view.Id,
                Name = view.Name,
                ParentAreaId = view.ParentAreaId == 0 ? null : view.ParentAreaId,
                AreaClient = view.AreaClient
            };
        }
    }
}